<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <div><button @click="handleBtn">改变名字</button></div>
        <div>{{getUserName}}</div>
    </div>
    <script src="../../js/vue.js"></script>
    <script>
        const dcl = {
            data() {
                return {
                    firstName: 'Steve',
                    lastName: 'Jobs',
                    isFlag: true,
                    message: 'You are the best'
                }
            },
            computed: {
                getUserName: {
                    get: function () {

                        return this.firstName + this.lastName
                    },
                    set: function (newValue) {
                        console.log('newValue', newValue)
                        const name = newValue.split(' ')
                        this.firstName = name[0]
                        this.lastName = name[1]
                    }
                }
            },
            methods: {
                handleBtn() {
                    this.getUserName = 'coder dcl'
                }
            }
        }
        Vue.createApp(dcl).mount('#app');
    </script>
</body>

</html>